/*!
 * LMV v6.4.1
 * 
 * Copyright 2019 Autodesk, Inc.
 * All rights reserved.
 * 
 * This computer source code and related instructions and comments are the
 * unpublished confidential and proprietary information of Autodesk, Inc.
 * and are protected under Federal copyright and state trade secret law.
 * They may not be disclosed to, copied or used by any third party without
 * the prior written consent of Autodesk, Inc.
 * 
 * Autodesk Forge Viewer Usage Limitations:
 * 
 * The Autodesk Forge viewer can only be used to view files generated by
 * Autodesk Forge services. The Autodesk Forge Viewer JavaScript must be
 * delivered from an Autodesk hosted URL.
 */
Autodesk.Extensions.PixelCompare =
/******/ (function(modules) { // webpackBootstrap
/******/ 	// The module cache
/******/ 	var installedModules = {};
/******/
/******/ 	// The require function
/******/ 	function __webpack_require__(moduleId) {
/******/
/******/ 		// Check if module is in cache
/******/ 		if(installedModules[moduleId]) {
/******/ 			return installedModules[moduleId].exports;
/******/ 		}
/******/ 		// Create a new module (and put it into the cache)
/******/ 		var module = installedModules[moduleId] = {
/******/ 			i: moduleId,
/******/ 			l: false,
/******/ 			exports: {}
/******/ 		};
/******/
/******/ 		// Execute the module function
/******/ 		modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/ 		// Flag the module as loaded
/******/ 		module.l = true;
/******/
/******/ 		// Return the exports of the module
/******/ 		return module.exports;
/******/ 	}
/******/
/******/
/******/ 	// expose the modules object (__webpack_modules__)
/******/ 	__webpack_require__.m = modules;
/******/
/******/ 	// expose the module cache
/******/ 	__webpack_require__.c = installedModules;
/******/
/******/ 	// define getter function for harmony exports
/******/ 	__webpack_require__.d = function(exports, name, getter) {
/******/ 		if(!__webpack_require__.o(exports, name)) {
/******/ 			Object.defineProperty(exports, name, { enumerable: true, get: getter });
/******/ 		}
/******/ 	};
/******/
/******/ 	// define __esModule on exports
/******/ 	__webpack_require__.r = function(exports) {
/******/ 		if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
/******/ 			Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
/******/ 		}
/******/ 		Object.defineProperty(exports, '__esModule', { value: true });
/******/ 	};
/******/
/******/ 	// create a fake namespace object
/******/ 	// mode & 1: value is a module id, require it
/******/ 	// mode & 2: merge all properties of value into the ns
/******/ 	// mode & 4: return value when already ns object
/******/ 	// mode & 8|1: behave like require
/******/ 	__webpack_require__.t = function(value, mode) {
/******/ 		if(mode & 1) value = __webpack_require__(value);
/******/ 		if(mode & 8) return value;
/******/ 		if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
/******/ 		var ns = Object.create(null);
/******/ 		__webpack_require__.r(ns);
/******/ 		Object.defineProperty(ns, 'default', { enumerable: true, value: value });
/******/ 		if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
/******/ 		return ns;
/******/ 	};
/******/
/******/ 	// getDefaultExport function for compatibility with non-harmony modules
/******/ 	__webpack_require__.n = function(module) {
/******/ 		var getter = module && module.__esModule ?
/******/ 			function getDefault() { return module['default']; } :
/******/ 			function getModuleExports() { return module; };
/******/ 		__webpack_require__.d(getter, 'a', getter);
/******/ 		return getter;
/******/ 	};
/******/
/******/ 	// Object.prototype.hasOwnProperty.call
/******/ 	__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ 	// __webpack_public_path__
/******/ 	__webpack_require__.p = "";
/******/
/******/
/******/ 	// Load entry module and return exports
/******/ 	return __webpack_require__(__webpack_require__.s = "./extensions/PixelCompare/PixelCompare.js");
/******/ })
/************************************************************************/
/******/ ({

/***/ "./extensions/PixelCompare/PixelCompare.css":
/*!**************************************************!*\
  !*** ./extensions/PixelCompare/PixelCompare.css ***!
  \**************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {


var content = __webpack_require__(/*! !../../node_modules/css-loader!./PixelCompare.css */ "./node_modules/css-loader/index.js!./extensions/PixelCompare/PixelCompare.css");

if(typeof content === 'string') content = [[module.i, content, '']];

var transform;
var insertInto;



var options = {"hmr":true}

options.transform = transform
options.insertInto = undefined;

var update = __webpack_require__(/*! ../../node_modules/style-loader/lib/addStyles.js */ "./node_modules/style-loader/lib/addStyles.js")(content, options);

if(content.locals) module.exports = content.locals;

if(false) {}

/***/ }),

/***/ "./extensions/PixelCompare/PixelCompare.js":
/*!*************************************************!*\
  !*** ./extensions/PixelCompare/PixelCompare.js ***!
  \*************************************************/
/*! no exports provided */
/***/ (function(module, __webpack_exports__, __webpack_require__) {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony import */ var _PixelCompareTool__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./PixelCompareTool */ "./extensions/PixelCompare/PixelCompareTool.js");
/* harmony import */ var _PixelCompare_css__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./PixelCompare.css */ "./extensions/PixelCompare/PixelCompare.css");
/* harmony import */ var _PixelCompare_css__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_PixelCompare_css__WEBPACK_IMPORTED_MODULE_1__);

 // IMPORTANT!!

//
// Pixel Compare
//

var av = Autodesk.Viewing;
var avp = av.Private;

function PixelCompare(viewer, options) {
  options = options || {};
  av.Extension.call(this, viewer, options);

  this.splitLineStyle = options.compareSplitLineStyle;

  this.DiffModes = Object.assign({}, avp.LeafletDiffModes);

  // Callback function for when the second model is loaded
  this.onSecondModelLoadedBinded = function (modelB) {
    var self = this;
    this.modelB = modelB;

    this.iterA = this.modelA.getIterator();
    this.iterB = this.modelB.getIterator();

    if (!av.isMobileDevice()) {
      this.iterA.setAggressivePrefetching(true);
      this.iterB.setAggressivePrefetching(true);
    }

    this.viewer.hideModel(this.modelA.id);

    var widthA = this.modelA.getData().loadOptions.loadOptions.texWidth;
    var widthB = this.modelB.getData().loadOptions.loadOptions.texWidth;

    this.iterA.setDpiScale(widthA > widthB && options.useDpiScaling ? widthB / widthA : 1);
    this.iterB.setDpiScale(widthB > widthA && options.useDpiScaling ? widthA / widthB : 1);

    // Init a leaflet compare iterator
    this.iterDiff = new avp.LeafletDiffIterator(this.iterA, this.iterB);

    this.modelDiff = new av.Model(this.modelA.getData());
    this.modelDiff.initFromCustomIterator(this.iterDiff);
    this.sceneDiff = this.iterDiff.getScene();

    if (this.viewer.loadSpinner) {
      // Show a spinner until the first scene is fully loaded
      this.sceneDiff.visible = false;
      this.viewer.loadSpinner.style.display = 'block';
      this.viewer.setNavigationLock(true);

      this.iterDiff.onFirstSceneComplete = function () {
        self.viewer.loadSpinner.style.display = 'none';
        self.sceneDiff.visible = true;
        self.viewer.setNavigationLock(false);

        if (options.onSceneReadyCB) {
          options.onSceneReadyCB();
        }
      };
    }

    // Show rendering progress when traversing the scene
    this.iterDiff.onProgress = function (progress) {
      self.viewer.impl.signalProgress(progress, av.ProgressState.RENDERING);
    };

    this.viewer.impl.addModel(this.modelDiff);

    this._loadTool();

    setTimeout(function () {self.viewer.utilities.fitToView(true);}, 1);

    return true;
  }.bind(this);
}

PixelCompare.prototype = Object.create(av.Extension.prototype);
PixelCompare.prototype.constructor = PixelCompare;

var proto = PixelCompare.prototype;

proto.load = function () {
  return true;
};

proto.unload = function () {
  if (this.tool) {
    this.viewer.toolController.deregisterTool(this.tool);
    this.tool = null;
  }

  this.endCompareWithCurrent(false);

  if (this.splitLineContainer) {
    this.viewer.container.removeChild(this.splitLineContainer);
    this.splitLineContainer = null;
  }

  return true;
};

proto._loadTool = function () {
  this.tool = new _PixelCompareTool__WEBPACK_IMPORTED_MODULE_0__["PixelCompareTool"](this.viewer, this.iterDiff);
  this.viewer.toolController.registerTool(this.tool);
};

/*
   * Initializes a comparison between two viewable paths
   * @param {string} viewablePathA - the first document viewable
   * @param {string} optionsA - options of the first document.
   * @param {string} viewablePathB - the second document viewable
   * @param {string} optionsB - options of the second document.
   * @param {function} [cbAfterFirstModel] - optional callback executed after the first model is loaded
   * @param {function} [cbAfterSecondModel] - optional callback executed after the second model is loaded
   * @returns {Promise} that resolves when all models are loaded
   */
proto.compareTwoViewables = function (viewablePathA, optionsA, viewablePathB, optionsB, cbAfterFirstModel, cbAfterSecondModel) {
  return this._compareTwoThings('_loadViewable', viewablePathA, optionsA, viewablePathB, optionsB, cbAfterFirstModel, cbAfterSecondModel);
};


/*
   * Initializes a comparison between two documents that have already been loaded
   * @param {string} docA - the first document location
   * @param {string} itemIdA - GUID of the first item.
   * @param {string} docB - the second document location
   * @param {string} itemIdB - GUID of the second item.
   * @param {function} [cbAfterFirstModel] - optional callback executed after the first model is loaded
   * @param {function} [cbAfterSecondModel] - optional callback executed after the second model is loaded
   * @returns {Promise} that resolves when all models are loaded
   */
proto.compareTwoDocuments = function (docA, itemIdA, docB, itemIdB, cbAfterFirstModel, cbAfterSecondModel) {
  return this._compareTwoThings('_loadDoc', docA, itemIdA, docB, itemIdB, cbAfterFirstModel, cbAfterSecondModel);
};

/*
    * Initializes a comparison between two models
    * @param {string} urnA - the first document location
    * @param {string} itemIdA - GUID of the first item.
    * @param {string} urnB - the second document location
    * @param {string} itemIdB - GUID of the second item.
    * @param {function} [cbAfterFirstModel] - optional callback executed after the first model is loaded
    * @param {function} [cbAfterSecondModel] - optional callback executed after the second model is loaded
    * @returns {Promise} that resolves when all models are loaded
    */
proto.compareTwoURNs = function (urnA, itemIdA, urnB, itemIdB, cbAfterFirstModel, cbAfterSecondModel) {
  return this._compareTwoThings('_loadModel', urnA, itemIdA, urnB, itemIdB, cbAfterFirstModel, cbAfterSecondModel);
};

proto._compareTwoThings = function (thingLoader, thingA, parameterA, thingB, parameterB, cbAfterFirstModel, cbAfterSecondModel) {
  var self = this;
  return this[thingLoader](thingA, parameterA, true, function (modelA) {
    if (!modelA || !modelA.getData().isLeaflet) {
      avp.logger.error('No model loaded to compare to or model is not leaflet');
      return false;
    }
    self.modelA = modelA;
    self.viewer.hideModel(modelA.id);
    self.viewer.impl.model = modelA; // Hide model will set it to null

    return true;
  }).then(function () {
    if (cbAfterFirstModel) {
      cbAfterFirstModel();
    }
    return self[thingLoader](thingB, parameterB, false, self.onSecondModelLoadedBinded);
  }).then(function () {
    if (cbAfterSecondModel) {
      cbAfterSecondModel();
    }
  }).catch(function (error) {
    avp.logger.error('PixelCompare: Error:', error);
  });
};

/*
    * Initializes a comparison with the currently loaded model
    * @param {string} urn - the document location
    * @param {string} itemId - GUID of the item.
    * @returns {Promise} that resolves when model is loaded
    */
proto.compareModelWithCurrent = function (urn, itemId) {
  this.modelA = this.viewer.model;
  if (!this.modelA || !this.modelA.getData().isLeaflet) {
    avp.logger.error('No model loaded to compare to or model is not leaflet');
    return Promise.reject({ reason: 'no-suitable-first-model' });
  }

  return this._loadModel(urn, itemId, false, this.onSecondModelLoadedBinded);
};

/*
   * Ends the current comparison
   * @param {boolean} restoreModelA - whether to restore the visibility of the first (original) model
   */
proto.endCompareWithCurrent = function (restoreModelA) {
  restoreModelA = restoreModelA === undefined ? true : restoreModelA;

  if (this.iterA) {
    this.iterA.setAggressivePrefetching(false);
  }

  if (this.modelB) {
    this.viewer.impl.unloadModel(this.modelDiff);
    this.viewer.impl.unloadModel(this.modelB);

    this.modelDiff = this.modelB = null;
  }

  if (this.tool && this.tool.isActive()) {
    this.setChangeOffsetMode(false);
  }

  if (this.modelA && restoreModelA) {
    this.viewer.showModel(this.modelA.id);

    var self = this;
    setTimeout(function () {
      self.viewer.utilities.fitToView(true);
    }, 1);
  }
};

/*
    * Sets the offset for the second model
    * @param {THREE.Vector3} offset
    */
proto.setOffset = function (offset) {
  if (this.iterDiff) {
    this.iterDiff.setOffset(offset);
    this.viewer.impl.invalidate(true, true);
  }
};

/*
    * Split position from 0 to 1 (left to right) percent of the screen width. Used in this.DiffModes.SPLIT_VIEW
    * @param {Number} pos
    */
proto.setSplitPosition = function (pos) {
  if (this.iterDiff) {
    this.iterDiff.setSplitPosition(pos);
    this.viewer.impl.invalidate(true, true);
  }
};

/**
    * Adds a split line element that can be dragged to change the split position
    * @private
    */
proto._addSplitLine = function () {
  this.splitLineContainer = document.createElement('div');
  this.splitLineContainer.className = 'pixel-compare-splitter';

  var splitLine = document.createElement('div');
  splitLine.className = 'pixel-compare-splitter-center-mark';
  this.splitLineContainer.appendChild(splitLine);

  if (this.splitLineStyle) {
    var width = this.splitLineStyle.width;
    var color = this.splitLineStyle.color;
    if (width) {
      width = 2 * Math.round(width / 2); // Round to nearest even number
      var containerWidth = Math.max(width, 16);
      this.splitLineContainer.style.width = containerWidth + 'px';
      this.splitLineContainer.style.left = 'calc(50% - ' + containerWidth / 2 + 'px)';
      splitLine.style.width = width + 'px';
      splitLine.style.left = (containerWidth - width) / 2 + 'px';
    }
    if (color) {
      splitLine.style.background = color;
    }
  }

  var isTouchEvent = false;

  var handleDown = function (e) {
    isTouchEvent = _PixelCompareTool__WEBPACK_IMPORTED_MODULE_0__["Utils"].isTouchEvent(e);
    _PixelCompareTool__WEBPACK_IMPORTED_MODULE_0__["Utils"].addRemoveInputEvents(document, 'move', handleMove);
    _PixelCompareTool__WEBPACK_IMPORTED_MODULE_0__["Utils"].addRemoveInputEvents(document, 'up', handleUp);
    e.preventDefault();
  }.bind(this);

  var handleMove = function (e) {
    if (isTouchEvent !== _PixelCompareTool__WEBPACK_IMPORTED_MODULE_0__["Utils"].isTouchEvent(e)) return;

    var rect = this.viewer.impl.getCanvasBoundingClientRect();
    var splitWidth = this.splitLineContainer.offsetWidth;

    var adjustedPos = _PixelCompareTool__WEBPACK_IMPORTED_MODULE_0__["Utils"].getClientCoords(e).x - rect.left;
    var posRatio = adjustedPos / rect.width;
    var posPercentage = posRatio * 100;

    var limit = 10; // Avoid dragging outside of the view bounds
    if (limit < posPercentage && posPercentage < 100 - limit) {
      this.splitLineContainer.style.left = 'calc(' + posPercentage + '% - ' + splitWidth / 2 + 'px)';
      this.setSplitPosition(posRatio);
      e.preventDefault();
    }
  }.bind(this);

  var handleUp = function (e) {
    _PixelCompareTool__WEBPACK_IMPORTED_MODULE_0__["Utils"].addRemoveInputEvents(document, 'move', handleMove, true);
    _PixelCompareTool__WEBPACK_IMPORTED_MODULE_0__["Utils"].addRemoveInputEvents(document, 'up', handleUp, true);
    e.preventDefault();
  }.bind(this);

  _PixelCompareTool__WEBPACK_IMPORTED_MODULE_0__["Utils"].addRemoveInputEvents(this.splitLineContainer, 'down', handleDown);

  this.setSplitPosition(0.5);
  this.viewer.container.appendChild(this.splitLineContainer);
};

/*
    * Changes the comparison mode
    * @param {Number} mode. Modes are in this.DiffModes
    */
proto.setDiffMode = function (mode) {
  this.iterDiff && this.iterDiff.setDiffMode(mode);
  if (mode === this.DiffModes.SPLIT_VIEW) {
    if (!this.splitLineContainer) {
      this._addSplitLine();
    }

    this.splitLineContainer.style.display = 'block';
  } else {
    if (this.splitLineContainer) {
      this.splitLineContainer.style.display = 'none';
    }
  }
};

/*
    * Enables the offset changing mode, to align document
    * @param {boolean} enable
    */
proto.setChangeOffsetMode = function (enable) {
  if (enable) {
    this.viewer.toolController.activateTool('pixelCompare');
    this.tool.setOffsetSettingMode(true);
  } else {
    this.tool.setOffsetSettingMode(false);
    this.viewer.toolController.deactivateTool('pixelCompare');
  }
};


proto._getDocGeometry = function (document, guid) {

  if (guid) {
    var item = document.getRoot().findByGuid(guid);
    if (item)
    return item;
  }

  var geometryItems = document.getRoot().search(av.BubbleNode.SHEET_NODE);

  return geometryItems[0];
};

proto._getViewable = function (document, guid) {
  var geometryItem = this._getDocGeometry(document, guid);

  if (!geometryItem) {
    return null;
  }

  var docOptions = {
    ids: null,
    sharedPropertyDbPath: document.getPropertyDbPath(),
    acmSessionId: document.acmSessionId,
    loadOptions: {} };


  var path = document.getViewablePath(geometryItem, docOptions.loadOptions);

  var match = path.toLowerCase().match(/\.([a-z0-9]+)(\?|$)/);
  var fileExtension = match ? match[1] : null;

  var loader = av.FileLoaderManager.getFileLoaderForExtension(fileExtension);
  if (loader !== avp.LeafletLoader) {
    avp.logger.error('File extension not supported:' + fileExtension, av.errorCodeString(av.ErrorCodes.UNSUPORTED_FILE_EXTENSION));
    return null;
  }

  return {
    path: path,
    options: docOptions };

};

proto._loadViewable = function (viewablePath, options, addModel, cb) {

  var self = this;

  return new Promise(function (resolve, reject) {

    var loadAndAddModel = function loadAndAddModel() {

      function onDone(model) {
        if (cb(model)) {
          resolve(true);
        } else {
          reject('error-in-model-cb');
        }
      }

      self.viewer.loadModel(viewablePath, options, onDone);
    };

    var loadWithoutAddingModel = function loadWithoutAddingModel() {

      function onDone(error, model) {
        if (error) {
          avp.logger.error('Error loading leaflet file for compare', error);
          reject('error-loading-leaflet-model');
          return;
        }

        setTimeout(function () {
          if (cb(model)) {
            resolve(true);
          } else {
            reject('error-in-model-cb');
          }
        });
      }

      var lefletLoader = new avp.LeafletLoader(self.viewer.impl);
      lefletLoader.loadFile(viewablePath, options, onDone);
    };

    if (addModel) {
      loadAndAddModel();
    } else {
      loadWithoutAddingModel();
    }
  });
};

proto._loadDoc = function (doc, itemId, addModel, cb) {

  var viewable = this._getViewable(doc, itemId);

  return this._loadViewable(viewable.path, viewable.options, addModel, cb);
};

/*
    * Loads a 2D model
    */
proto._loadModel = function (urn, itemId, addModel, cb) {
  var self = this;

  return new Promise(function (resolve, reject) {

    var onLoad = function onLoad(doc) {
      self._loadDoc(doc, itemId, addModel, cb).then(function () {
        resolve(true);
      }).catch(function (err) {
        reject(err);
      });
    };

    var onError = function onError(error) {
      avp.logger.error('PixelCompare: Error loading urn', error);
      reject(error);
    };


    av.Document.load(urn, onLoad, onError, null);
  });
};

av.theExtensionManager.registerExtension('Autodesk.Viewing.PixelCompare', PixelCompare);

/***/ }),

/***/ "./extensions/PixelCompare/PixelCompareTool.js":
/*!*****************************************************!*\
  !*** ./extensions/PixelCompare/PixelCompareTool.js ***!
  \*****************************************************/
/*! exports provided: PixelCompareTool, Utils */
/***/ (function(module, __webpack_exports__, __webpack_require__) {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PixelCompareTool", function() { return PixelCompareTool; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Utils", function() { return Utils; });



var av = Autodesk.Viewing;

var PixelCompareTool = function PixelCompareTool(viewer, iterDiff) {
  av.ToolInterface.call(this);
  this.names = ['pixelCompare'];

  var _isActive = false;
  var _isSettingOffset = false;
  var _dragging = false;
  var _startDrag = null;
  var _curOffset = null;

  /**
                          * Sets the offset changing mode
                          * @param {boolean} enable
                          */
  this.setOffsetSettingMode = function (enable) {
    _isSettingOffset = enable;
  };

  this.isActive = function () {
    return _isActive;
  };

  this.activate = function (name) {
    _isActive = true;
  };

  this.deactivate = function (name) {
    _isActive = false;
  };

  this.handleButtonDown = function (event, button) {
    if (!_isSettingOffset || button !== 0) return false;

    _curOffset = iterDiff.getOffset();
    _startDrag = clientToWorld(viewer, event.canvasX, event.canvasY);
    _dragging = true;

    return true;
  };

  this.handleButtonUp = function (event, button) {
    if (!_isSettingOffset || button !== 0) return false;

    _dragging = false;

    return true;
  };

  /**
      * Specialize base class implementation
      */
  this.handleMouseMove = function (event) {
    if (!_dragging) return false;

    var drag = clientToWorld(viewer, event.canvasX, event.canvasY);
    var newOffset = drag.sub(_startDrag).add(_curOffset);
    iterDiff.setOffset(newOffset);
    viewer.impl.invalidate(true, true);

    return true;
  };

  this.handleGesture = function (event) {
    switch (event.type) {

      case 'dragstart':
        return this.handleButtonDown(event);

      case 'dragmove':
        return this.handleMouseMove(event);

      case 'dragend':
        return this.handleButtonUp(event);}

    return false;
  };

  this.getCursor = function () {
    return _isSettingOffset ? 'move' : null;
  };
};

var inputMap = {
  down: {
    pointer: 'pointerdown',
    mouse: 'mousedown',
    touch: 'touchstart' },

  up: {
    pointer: 'pointerup',
    mouse: 'mouseup',
    touch: 'touchend' },

  move: {
    pointer: 'pointermove',
    mouse: 'mousemove',
    touch: 'touchmove' } };



function _getInputEvents(type) {
  if (av.isIE11)
  return [inputMap[type]['pointer']];

  var events = [];
  if (!av.isMobileDevice())
  events.push(inputMap[type]['mouse']);

  if (av.isTouchDevice())
  events.push(inputMap[type]['touch']);

  return events;
}

function getClientCoords(event) {
  if (av.isIE11)
  return { x: event.clientX, y: event.clientY };

  return event.type.startsWith('touch') ?
  { x: event.touches[0].clientX, y: event.touches[0].clientY } :
  { x: event.clientX, y: event.clientY };
}

function isTouchEvent(event) {
  if (av.isIE11)
  return event.pointerType === 'touch';

  return event.type.startsWith('touch');
}

function addRemoveInputEvents(elem, type, cb, isRemoving) {
  isRemoving = !!isRemoving;
  var action = (isRemoving ? 'remove' : 'add') + 'EventListener';
  var events = _getInputEvents(type);
  events.forEach(function (event) {
    elem[action](event, cb);
  });
}

function clientToWorld(viewer, x, y) {

  var worldPos = viewer.impl.clientToViewport(x, y);
  worldPos.unproject(viewer.impl.camera);

  return worldPos;
}

var Utils = {
  getClientCoords: getClientCoords,
  isTouchEvent: isTouchEvent,
  addRemoveInputEvents: addRemoveInputEvents,
  clientToWorld: clientToWorld };

/***/ }),

/***/ "./node_modules/css-loader/index.js!./extensions/PixelCompare/PixelCompare.css":
/*!****************************************************************************!*\
  !*** ./node_modules/css-loader!./extensions/PixelCompare/PixelCompare.css ***!
  \****************************************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {

exports = module.exports = __webpack_require__(/*! ../../node_modules/css-loader/lib/css-base.js */ "./node_modules/css-loader/lib/css-base.js")(false);
// imports


// module
exports.push([module.i, ".pixel-compare-splitter {\n    background: transparent;\n    width: 16px;\n    height: 100%;\n    position: absolute;\n    top: 0px;\n    left: calc(50% - 8px);\n    z-index: 3;\n    display: none;\n    cursor: col-resize;\n}\n\n.pixel-compare-splitter-center-mark {\n    background: #73a9e8;\n    width: 1px;\n    height: 100%;\n    position: absolute;\n    left: 7.5px;\n}", ""]);

// exports


/***/ }),

/***/ "./node_modules/css-loader/lib/css-base.js":
/*!*************************************************!*\
  !*** ./node_modules/css-loader/lib/css-base.js ***!
  \*************************************************/
/*! no static exports found */
/***/ (function(module, exports) {

/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
// css base code, injected by the css-loader
module.exports = function(useSourceMap) {
	var list = [];

	// return the list of modules as css string
	list.toString = function toString() {
		return this.map(function (item) {
			var content = cssWithMappingToString(item, useSourceMap);
			if(item[2]) {
				return "@media " + item[2] + "{" + content + "}";
			} else {
				return content;
			}
		}).join("");
	};

	// import a list of modules into the list
	list.i = function(modules, mediaQuery) {
		if(typeof modules === "string")
			modules = [[null, modules, ""]];
		var alreadyImportedModules = {};
		for(var i = 0; i < this.length; i++) {
			var id = this[i][0];
			if(typeof id === "number")
				alreadyImportedModules[id] = true;
		}
		for(i = 0; i < modules.length; i++) {
			var item = modules[i];
			// skip already imported module
			// this implementation is not 100% perfect for weird media query combinations
			//  when a module is imported multiple times with different media queries.
			//  I hope this will never occur (Hey this way we have smaller bundles)
			if(typeof item[0] !== "number" || !alreadyImportedModules[item[0]]) {
				if(mediaQuery && !item[2]) {
					item[2] = mediaQuery;
				} else if(mediaQuery) {
					item[2] = "(" + item[2] + ") and (" + mediaQuery + ")";
				}
				list.push(item);
			}
		}
	};
	return list;
};

function cssWithMappingToString(item, useSourceMap) {
	var content = item[1] || '';
	var cssMapping = item[3];
	if (!cssMapping) {
		return content;
	}

	if (useSourceMap && typeof btoa === 'function') {
		var sourceMapping = toComment(cssMapping);
		var sourceURLs = cssMapping.sources.map(function (source) {
			return '/*# sourceURL=' + cssMapping.sourceRoot + source + ' */'
		});

		return [content].concat(sourceURLs).concat([sourceMapping]).join('\n');
	}

	return [content].join('\n');
}

// Adapted from convert-source-map (MIT)
function toComment(sourceMap) {
	// eslint-disable-next-line no-undef
	var base64 = btoa(unescape(encodeURIComponent(JSON.stringify(sourceMap))));
	var data = 'sourceMappingURL=data:application/json;charset=utf-8;base64,' + base64;

	return '/*# ' + data + ' */';
}


/***/ }),

/***/ "./node_modules/style-loader/lib/addStyles.js":
/*!****************************************************!*\
  !*** ./node_modules/style-loader/lib/addStyles.js ***!
  \****************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {

/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/

var stylesInDom = {};

var	memoize = function (fn) {
	var memo;

	return function () {
		if (typeof memo === "undefined") memo = fn.apply(this, arguments);
		return memo;
	};
};

var isOldIE = memoize(function () {
	// Test for IE <= 9 as proposed by Browserhacks
	// @see http://browserhacks.com/#hack-e71d8692f65334173fee715c222cb805
	// Tests for existence of standard globals is to allow style-loader
	// to operate correctly into non-standard environments
	// @see https://github.com/webpack-contrib/style-loader/issues/177
	return window && document && document.all && !window.atob;
});

var getTarget = function (target, parent) {
  if (parent){
    return parent.querySelector(target);
  }
  return document.querySelector(target);
};

var getElement = (function (fn) {
	var memo = {};

	return function(target, parent) {
                // If passing function in options, then use it for resolve "head" element.
                // Useful for Shadow Root style i.e
                // {
                //   insertInto: function () { return document.querySelector("#foo").shadowRoot }
                // }
                if (typeof target === 'function') {
                        return target();
                }
                if (typeof memo[target] === "undefined") {
			var styleTarget = getTarget.call(this, target, parent);
			// Special case to return head of iframe instead of iframe itself
			if (window.HTMLIFrameElement && styleTarget instanceof window.HTMLIFrameElement) {
				try {
					// This will throw an exception if access to iframe is blocked
					// due to cross-origin restrictions
					styleTarget = styleTarget.contentDocument.head;
				} catch(e) {
					styleTarget = null;
				}
			}
			memo[target] = styleTarget;
		}
		return memo[target]
	};
})();

var singleton = null;
var	singletonCounter = 0;
var	stylesInsertedAtTop = [];

var	fixUrls = __webpack_require__(/*! ./urls */ "./node_modules/style-loader/lib/urls.js");

module.exports = function(list, options) {
	if (typeof DEBUG !== "undefined" && DEBUG) {
		if (typeof document !== "object") throw new Error("The style-loader cannot be used in a non-browser environment");
	}

	options = options || {};

	options.attrs = typeof options.attrs === "object" ? options.attrs : {};

	// Force single-tag solution on IE6-9, which has a hard limit on the # of <style>
	// tags it will allow on a page
	if (!options.singleton && typeof options.singleton !== "boolean") options.singleton = isOldIE();

	// By default, add <style> tags to the <head> element
        if (!options.insertInto) options.insertInto = "head";

	// By default, add <style> tags to the bottom of the target
	if (!options.insertAt) options.insertAt = "bottom";

	var styles = listToStyles(list, options);

	addStylesToDom(styles, options);

	return function update (newList) {
		var mayRemove = [];

		for (var i = 0; i < styles.length; i++) {
			var item = styles[i];
			var domStyle = stylesInDom[item.id];

			domStyle.refs--;
			mayRemove.push(domStyle);
		}

		if(newList) {
			var newStyles = listToStyles(newList, options);
			addStylesToDom(newStyles, options);
		}

		for (var i = 0; i < mayRemove.length; i++) {
			var domStyle = mayRemove[i];

			if(domStyle.refs === 0) {
				for (var j = 0; j < domStyle.parts.length; j++) domStyle.parts[j]();

				delete stylesInDom[domStyle.id];
			}
		}
	};
};

function addStylesToDom (styles, options) {
	for (var i = 0; i < styles.length; i++) {
		var item = styles[i];
		var domStyle = stylesInDom[item.id];

		if(domStyle) {
			domStyle.refs++;

			for(var j = 0; j < domStyle.parts.length; j++) {
				domStyle.parts[j](item.parts[j]);
			}

			for(; j < item.parts.length; j++) {
				domStyle.parts.push(addStyle(item.parts[j], options));
			}
		} else {
			var parts = [];

			for(var j = 0; j < item.parts.length; j++) {
				parts.push(addStyle(item.parts[j], options));
			}

			stylesInDom[item.id] = {id: item.id, refs: 1, parts: parts};
		}
	}
}

function listToStyles (list, options) {
	var styles = [];
	var newStyles = {};

	for (var i = 0; i < list.length; i++) {
		var item = list[i];
		var id = options.base ? item[0] + options.base : item[0];
		var css = item[1];
		var media = item[2];
		var sourceMap = item[3];
		var part = {css: css, media: media, sourceMap: sourceMap};

		if(!newStyles[id]) styles.push(newStyles[id] = {id: id, parts: [part]});
		else newStyles[id].parts.push(part);
	}

	return styles;
}

function insertStyleElement (options, style) {
	var target = getElement(options.insertInto)

	if (!target) {
		throw new Error("Couldn't find a style target. This probably means that the value for the 'insertInto' parameter is invalid.");
	}

	var lastStyleElementInsertedAtTop = stylesInsertedAtTop[stylesInsertedAtTop.length - 1];

	if (options.insertAt === "top") {
		if (!lastStyleElementInsertedAtTop) {
			target.insertBefore(style, target.firstChild);
		} else if (lastStyleElementInsertedAtTop.nextSibling) {
			target.insertBefore(style, lastStyleElementInsertedAtTop.nextSibling);
		} else {
			target.appendChild(style);
		}
		stylesInsertedAtTop.push(style);
	} else if (options.insertAt === "bottom") {
		target.appendChild(style);
	} else if (typeof options.insertAt === "object" && options.insertAt.before) {
		var nextSibling = getElement(options.insertAt.before, target);
		target.insertBefore(style, nextSibling);
	} else {
		throw new Error("[Style Loader]\n\n Invalid value for parameter 'insertAt' ('options.insertAt') found.\n Must be 'top', 'bottom', or Object.\n (https://github.com/webpack-contrib/style-loader#insertat)\n");
	}
}

function removeStyleElement (style) {
	if (style.parentNode === null) return false;
	style.parentNode.removeChild(style);

	var idx = stylesInsertedAtTop.indexOf(style);
	if(idx >= 0) {
		stylesInsertedAtTop.splice(idx, 1);
	}
}

function createStyleElement (options) {
	var style = document.createElement("style");

	if(options.attrs.type === undefined) {
		options.attrs.type = "text/css";
	}

	if(options.attrs.nonce === undefined) {
		var nonce = getNonce();
		if (nonce) {
			options.attrs.nonce = nonce;
		}
	}

	addAttrs(style, options.attrs);
	insertStyleElement(options, style);

	return style;
}

function createLinkElement (options) {
	var link = document.createElement("link");

	if(options.attrs.type === undefined) {
		options.attrs.type = "text/css";
	}
	options.attrs.rel = "stylesheet";

	addAttrs(link, options.attrs);
	insertStyleElement(options, link);

	return link;
}

function addAttrs (el, attrs) {
	Object.keys(attrs).forEach(function (key) {
		el.setAttribute(key, attrs[key]);
	});
}

function getNonce() {
	if (false) {}

	return __webpack_require__.nc;
}

function addStyle (obj, options) {
	var style, update, remove, result;

	// If a transform function was defined, run it on the css
	if (options.transform && obj.css) {
	    result = typeof options.transform === 'function'
		 ? options.transform(obj.css) 
		 : options.transform.default(obj.css);

	    if (result) {
	    	// If transform returns a value, use that instead of the original css.
	    	// This allows running runtime transformations on the css.
	    	obj.css = result;
	    } else {
	    	// If the transform function returns a falsy value, don't add this css.
	    	// This allows conditional loading of css
	    	return function() {
	    		// noop
	    	};
	    }
	}

	if (options.singleton) {
		var styleIndex = singletonCounter++;

		style = singleton || (singleton = createStyleElement(options));

		update = applyToSingletonTag.bind(null, style, styleIndex, false);
		remove = applyToSingletonTag.bind(null, style, styleIndex, true);

	} else if (
		obj.sourceMap &&
		typeof URL === "function" &&
		typeof URL.createObjectURL === "function" &&
		typeof URL.revokeObjectURL === "function" &&
		typeof Blob === "function" &&
		typeof btoa === "function"
	) {
		style = createLinkElement(options);
		update = updateLink.bind(null, style, options);
		remove = function () {
			removeStyleElement(style);

			if(style.href) URL.revokeObjectURL(style.href);
		};
	} else {
		style = createStyleElement(options);
		update = applyToTag.bind(null, style);
		remove = function () {
			removeStyleElement(style);
		};
	}

	update(obj);

	return function updateStyle (newObj) {
		if (newObj) {
			if (
				newObj.css === obj.css &&
				newObj.media === obj.media &&
				newObj.sourceMap === obj.sourceMap
			) {
				return;
			}

			update(obj = newObj);
		} else {
			remove();
		}
	};
}

var replaceText = (function () {
	var textStore = [];

	return function (index, replacement) {
		textStore[index] = replacement;

		return textStore.filter(Boolean).join('\n');
	};
})();

function applyToSingletonTag (style, index, remove, obj) {
	var css = remove ? "" : obj.css;

	if (style.styleSheet) {
		style.styleSheet.cssText = replaceText(index, css);
	} else {
		var cssNode = document.createTextNode(css);
		var childNodes = style.childNodes;

		if (childNodes[index]) style.removeChild(childNodes[index]);

		if (childNodes.length) {
			style.insertBefore(cssNode, childNodes[index]);
		} else {
			style.appendChild(cssNode);
		}
	}
}

function applyToTag (style, obj) {
	var css = obj.css;
	var media = obj.media;

	if(media) {
		style.setAttribute("media", media)
	}

	if(style.styleSheet) {
		style.styleSheet.cssText = css;
	} else {
		while(style.firstChild) {
			style.removeChild(style.firstChild);
		}

		style.appendChild(document.createTextNode(css));
	}
}

function updateLink (link, options, obj) {
	var css = obj.css;
	var sourceMap = obj.sourceMap;

	/*
		If convertToAbsoluteUrls isn't defined, but sourcemaps are enabled
		and there is no publicPath defined then lets turn convertToAbsoluteUrls
		on by default.  Otherwise default to the convertToAbsoluteUrls option
		directly
	*/
	var autoFixUrls = options.convertToAbsoluteUrls === undefined && sourceMap;

	if (options.convertToAbsoluteUrls || autoFixUrls) {
		css = fixUrls(css);
	}

	if (sourceMap) {
		// http://stackoverflow.com/a/26603875
		css += "\n/*# sourceMappingURL=data:application/json;base64," + btoa(unescape(encodeURIComponent(JSON.stringify(sourceMap)))) + " */";
	}

	var blob = new Blob([css], { type: "text/css" });

	var oldSrc = link.href;

	link.href = URL.createObjectURL(blob);

	if(oldSrc) URL.revokeObjectURL(oldSrc);
}


/***/ }),

/***/ "./node_modules/style-loader/lib/urls.js":
/*!***********************************************!*\
  !*** ./node_modules/style-loader/lib/urls.js ***!
  \***********************************************/
/*! no static exports found */
/***/ (function(module, exports) {


/**
 * When source maps are enabled, `style-loader` uses a link element with a data-uri to
 * embed the css on the page. This breaks all relative urls because now they are relative to a
 * bundle instead of the current page.
 *
 * One solution is to only use full urls, but that may be impossible.
 *
 * Instead, this function "fixes" the relative urls to be absolute according to the current page location.
 *
 * A rudimentary test suite is located at `test/fixUrls.js` and can be run via the `npm test` command.
 *
 */

module.exports = function (css) {
  // get current location
  var location = typeof window !== "undefined" && window.location;

  if (!location) {
    throw new Error("fixUrls requires window.location");
  }

	// blank or null?
	if (!css || typeof css !== "string") {
	  return css;
  }

  var baseUrl = location.protocol + "//" + location.host;
  var currentDir = baseUrl + location.pathname.replace(/\/[^\/]*$/, "/");

	// convert each url(...)
	/*
	This regular expression is just a way to recursively match brackets within
	a string.

	 /url\s*\(  = Match on the word "url" with any whitespace after it and then a parens
	   (  = Start a capturing group
	     (?:  = Start a non-capturing group
	         [^)(]  = Match anything that isn't a parentheses
	         |  = OR
	         \(  = Match a start parentheses
	             (?:  = Start another non-capturing groups
	                 [^)(]+  = Match anything that isn't a parentheses
	                 |  = OR
	                 \(  = Match a start parentheses
	                     [^)(]*  = Match anything that isn't a parentheses
	                 \)  = Match a end parentheses
	             )  = End Group
              *\) = Match anything and then a close parens
          )  = Close non-capturing group
          *  = Match anything
       )  = Close capturing group
	 \)  = Match a close parens

	 /gi  = Get all matches, not the first.  Be case insensitive.
	 */
	var fixedCss = css.replace(/url\s*\(((?:[^)(]|\((?:[^)(]+|\([^)(]*\))*\))*)\)/gi, function(fullMatch, origUrl) {
		// strip quotes (if they exist)
		var unquotedOrigUrl = origUrl
			.trim()
			.replace(/^"(.*)"$/, function(o, $1){ return $1; })
			.replace(/^'(.*)'$/, function(o, $1){ return $1; });

		// already a full url? no change
		if (/^(#|data:|http:\/\/|https:\/\/|file:\/\/\/|\s*$)/i.test(unquotedOrigUrl)) {
		  return fullMatch;
		}

		// convert the url to a full url
		var newUrl;

		if (unquotedOrigUrl.indexOf("//") === 0) {
		  	//TODO: should we add protocol?
			newUrl = unquotedOrigUrl;
		} else if (unquotedOrigUrl.indexOf("/") === 0) {
			// path should be relative to the base url
			newUrl = baseUrl + unquotedOrigUrl; // already starts with '/'
		} else {
			// path should be relative to current directory
			newUrl = currentDir + unquotedOrigUrl.replace(/^\.\//, ""); // Strip leading './'
		}

		// send back the fixed url(...)
		return "url(" + JSON.stringify(newUrl) + ")";
	});

	// send back the fixed css
	return fixedCss;
};


/***/ })

/******/ });